package org.jader.bolao.gui.swing;

import java.awt.FlowLayout;
import java.awt.Frame;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

public class SplashScreen extends JDialog implements Runnable {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	//private JLabel imageLabel = null;
	private JLabel textLabel = null;
	
	/**
	 * @param owner
	 */
	public SplashScreen(Frame owner) {
		super(owner);
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(220, 65);
		this.setResizable(false);
		this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		this.setTitle("Carregando...");
		this.setContentPane(getJContentPane());
		this.setModal(true);
		this.setLocationRelativeTo(this.getParent());
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			//imageLabel = new JLabel(new ImageIcon(getClass().getResource("images/loading2.gif")));
			textLabel = new JLabel();
			textLabel.setText("Aguarde alguns instantes...");
			jContentPane = new JPanel();
			jContentPane.setLayout(new FlowLayout());
			//jContentPane.add(imageLabel, null);
			jContentPane.add(textLabel, null);
		}
		return jContentPane;
	}

	@Override
	public void run() {
		this.setVisible(true);
		getJContentPane().repaint();
	}
	
	public static void main(String args[]) {
		SplashScreen ss = new SplashScreen(null); 
		new Thread(ss).start();
		try {
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		ss.dispose();
	}
}  //  @jve:decl-index=0:visual-constraint="16,7"
